//
//  STTimerDayCell.m
//  YiYueHairdresser
//
//  Created by zhouzhouzhou on 2018/10/12.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STTimerDayCell.h"
#import "UIButton+ZYHblock.h"
#import "SWServiceModel.h"
@implementation STTimerDayCell


- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // 初始化时加载collectionCell.xib文件
        NSArray *arrayOfViews =
        [[NSBundle mainBundle] loadNibNamed:@"STTimerDayCell"
                                      owner:self
                                    options:nil];
        
        self = [arrayOfViews objectAtIndex:0];
    }
    return self;
}



-(void)setOwnCollectionCellWithData:(id)data{
//    [self.dayBtn setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forState:UIControlStateNormal];
//    [self.dayBtn setBackgroundImage:[UIImage imageWithColor:[UIColor orangeColor]] forState:UIControlStateSelected];
    
//    [self.dayBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
//    [self.dayBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    
    self.dayBtn.backgroundColor = [UIColor whiteColor];
    [self.dayBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    NSString * name;
    if ([data isKindOfClass:[NSDictionary class]]) {
        NSDictionary * dicData =data;
        name = dicData[@"name"];
    }else if ([data isKindOfClass:[NSString class]]) {
        name = data;
    }else if ([data isKindOfClass:[STDoorServiceModel class]]) {
        STDoorServiceModel * modelData =data;
        name = modelData.name;
    }else if ([data isKindOfClass:[SWServiceModel class]]) {
        SWServiceModel * modelData =data;
        name = modelData.name;
        self.dayBtn.tag = modelData.ID;
    }
    
    [self.dayBtn setTitle:name forState:UIControlStateNormal];
    [self.dayBtn setTitle:name forState:UIControlStateSelected];
    self.dayBtn.layer.cornerRadius = 5;
    self.dayBtn.layer.masksToBounds = YES;
    self.dayBtn.layer.borderWidth = 1;
    self.dayBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.dayBtn.enabled = NO;
//    [self.dayBtn addTarget:self action:@selector(actionChangeDayBtn:) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)actionChangeDayBtn{
    self.isSel = !self.isSel;
    if (self.isSel) {
        self.dayBtn.backgroundColor = [UIColor orangeColor];
        [self.dayBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }else{
        self.dayBtn.backgroundColor = [UIColor whiteColor];
        [self.dayBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
}


//- (UIView *) hitTest:(CGPoint) point withEvent:(UIEvent *)event {
//   UIView * view =[super hitTest:point withEvent:event];
//    return view;
//}

@end
